% generate several views of a mechanical arm with 2 DOF
% in a temporal sequence

close all;
clear all;
dbstop if error;

figure; fig1 = gcf;
figure; fig2 = gcf;
figure; fig3 = gcf;

[verts1o verts2o solid] = GenBaseVerts;

for phi = -pi/4:.05:pi/4
    for theta = 0:.2:2*pi
        verts1 = verts1o;
        verts2 = verts2o;
        [verts1 verts2] = TransformVerts(verts1,verts2,theta,phi);
        solid.X1 = verts1';
        solid.X2 = verts2';
        
        figure(fig1);
        pos1 = [-20 -20 20];
        tar1 = [0 0 0];
        DrawSurfsFromVerts(solid);
        %DrawVerts(verts1,verts2);
        set( gca, 'Projection', 'perspective','CameraPosition',pos1, ...
            'CameraTarget',tar1);
        drawnow;
        
        figure(fig2);
        pos2 = [20 20 20];
        tar2 = [0 0 0];
        DrawSurfsFromVerts(solid);
        %DrawVerts(verts1,verts2);
        set( gca, 'Projection', 'perspective','CameraPosition',pos2, ...
            'CameraTarget',tar2);
        drawnow;
        
        figure(fig3);
        pos3 = [0 20 20];
        tar3 = [0 0 0];
        DrawSurfsFromVerts(solid);
        %DrawVerts(verts1,verts2);
        set( gca, 'Projection', 'perspective','CameraPosition',pos3, ...
            'CameraTarget',tar3);
        drawnow;
        

    end
end

